home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 101-125 / disk_107 / svtools / fragit / fragit.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  114 lines

  1. /************************************************************
  2.   fragit.c  By: Stephen Vermeulen
  3.  
  4.   This program is a demonstration of how one can fragment
  5.   (usually temporarly) CHIP ram.
  6.  
  7.   To get this to work from CLI you must do the following:
  8.  
  9.     1 - Open a pair of CLI windows, make one cover the whole
  10.         display and the other cover at least a half of the
  11.         display.
  12.  
  13.     2 - run Avail or memlist to see what the largest free
  14.         CHIP memory chunk in the chip section is.
  15.  
  16.     3 - run Fragit, a small window will appear briefly in the
  17.         middle of the workbench, the workbench screen will
  18.         then be covered by a big screen, the little window
  19.         will be closed, then the big screen will be closed.
  20.  
  21.     4 - run Avail or memlist again and note that while the
  22.         total amount of free CHIP memory remains the same, the
  23.         distribution is different, the one huge chunk has got
  24.         split up!  Nasty!
  25.  
  26.     5 - move the smaller cli window slightly, or resize it a bit
  27.         and then run Avail or memlist again to see that the
  28.         CHIP chunks change size and the big chunk returns!
  29.  
  30.     6 - Note that if you try this process when the little
  31.         window that the program opens only overlaps ONE window
  32.         on the workbench nothing untoward happens.  It seems to
  33.         be a problem when windows get stacked THREE deep somewhere.
  34.  
  35.   compile with Manx 3.4a
  36. ************************************************************/
  37.  
  38. #include <intuition/intuition.h>
  39. #include <graphics/gfx.h>
  40. #include <graphics/display.h>
  41. #include <exec/memory.h>
  42. #include <functions.h>
  43.  
  44. struct IntuitionBase *IntuitionBase;
  45.  
  46. /***************************************
  47.   This specifies the custom screen that
  48.   our program will open briefly
  49. ****************************************/
  50.  
  51. struct NewScreen my_s =
  52. {
  53.   0, 0, 640, 400, 4,
  54.   0, 1, LACE | HIRES, CUSTOMSCREEN,
  55.   NULL,                    /* force the font to topaz 80 */
  56.   NULL,                       /* screen title */
  57.   NULL,                       /* still no screen gadgets in Amiga */
  58.   NULL                        /* let Intuition give us bitmap */
  59. };
  60.  
  61. /****************************************
  62.   Temp window is the user friendly prompt
  63.   that causes the memory fragmentation.
  64. *****************************************/
  65.  
  66. struct NewWindow temp_window =
  67. {
  68.   200, 100, 240, 14,
  69.   -1, -1,
  70.                         /* these are the message events we want to use */
  71.   NULL,
  72.  
  73.   SMART_REFRESH | NOCAREREFRESH,
  74.   NULL,               /* this is where gadgets go */
  75.   NULL,                 /* default checkmark */
  76.   NULL, /* not title */
  77.   NULL,                 /* on the workbench */
  78.   NULL,
  79.   0, 0, -1, -1,         /* don't care as no sizing is allowed */
  80.   WBENCHSCREEN
  81. };
  82.  
  83. /************************************************************
  84.   The main routine just opens the various libraries, allocates
  85.   memory, opens the main window.  Then after a 2 second pause
  86.   closes it all.
  87. *************************************************************/
  88.  
  89. void main(argc, argv)
  90. short argc;
  91. char *argv[];
  92. {
  93.   struct Screen *s;
  94.   struct Window *tw;
  95.  
  96.   IntuitionBase = (struct IntuitionBase *)
  97.                   OpenLibrary("intuition.library", 0L);
  98.   if (IntuitionBase)
  99.   {
  100.     tw = OpenWindow(&temp_window);
  101.     Delay(60L);
  102.     s = (struct Screen *) OpenScreen(&my_s);
  103.     if (s)
  104.     {
  105.       Delay(60L);
  106.       if (tw) CloseWindow(tw);
  107.       tw = NULL;
  108.       CloseScreen(s);
  109.     }
  110.     if (tw) CloseWindow(tw);
  111.   }
  112.   CloseLibrary(IntuitionBase);
  113. }
  114.